using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using net_work.Data.Entity.Sys;

namespace net_work.Config.DataBaseConfig.Sys;

/// <summary>
/// 行政班级实体配置类
/// </summary>
public class AdministrativeClassEntityTypeConfiguration : IEntityTypeConfiguration<AdministrativeClass>
{
    public void Configure(EntityTypeBuilder<AdministrativeClass> builder)
    {
        builder.ToTable("sys_adm_class");

        builder.HasKey(c => c.Id);

        builder.HasIndex(c => c.ClassName).IsUnique();

        // 配置字段名映射
        builder.Property(c => c.Id).HasColumnName("class_id");
        builder.Property(c => c.ClassName).HasColumnName("class_name").IsRequired().HasMaxLength(64);
        builder.Property(c => c.ClassGrade).HasColumnName("class_grade").IsRequired();
        builder.Property(c => c.ClassNum).HasColumnName("class_num").IsRequired();
        builder.Property(c => c.HeadTeacherId).HasColumnName("head_tcr_id").IsRequired();
        builder.Property(c => c.CollegeId).HasColumnName("colle_id").IsRequired();

        builder.Property(c => c.CreatedBy).HasColumnName("create_by").IsRequired().HasMaxLength(64);
        builder.Property(c => c.CreatedTime).HasColumnName("create_time").IsRequired();
        builder.Property(c => c.UpdatedBy).HasColumnName("update_by").IsRequired().HasMaxLength(64);
        builder.Property(c => c.UpdatedTime).HasColumnName("update_time").IsRequired();
        builder.Property(c => c.Remark).HasColumnName("remark").HasMaxLength(256);
        builder.Property(c => c.DelFlag).HasColumnName("del_flag").HasDefaultValue('0');
    }
}